#coding:utf-8
# from homeapp.models import TTest
from homeapp.models import TLog
# import uuid

class tlog_dal():

    @staticmethod
    def selectlog():

        # 得到 tlog 列表
        sql = "select * from homeapp_tlog;"
        objects = TLog.objects.raw(sql)

        return objects

    @staticmethod
    def selectbyguids(guids):

        # 得到guids的个数
        guidcount = len(guids)
        zo = 0

        # 拼接sql字符串
        strsql = "select homeapp_tnote.guid, homeapp_tnote.guid as mguid, Path, homeapp_tnotetype.guid, homeapp_tnotetype.guid as tguid, Text, TypeName from homeapp_tnote join homeapp_tnotetype on homeapp_tnote.NoteType_Guid = homeapp_tnotetype.guid where homeapp_tnote.guid in ("

        for guid in guids:
            if zo == guidcount - 1:
                strsql += "'" + guid + "')"
                zo += 1
            else:
                strsql += "'" + guid + "',"
                zo += 1

        objs = TLog.objects.raw(strsql)

        return objs
